// This is example source code. It demonstrates the use of the ACRViewer API.
// 
// Jens Breitenborn, 95/05/03

#import "ACRViewer.h"
#import <sys/param.h>

// All files specified in the command line are converted to TIFF files.
// The created TIFF files will be stored in the current directory.

main(int argc, char *argv[])
{
int i;
id acrviewer= [[ACRViewer alloc] init]; 
char outfilename[MAXPATHLEN+1];

	if (argc == 1){
		puts("usage:acr2tiff file-list");
		exit(1);
	}

	if (!acrviewer) {
		puts("Could not get API for ACRViewer!\n"
			 "Probably ACRViewer isn't placed in the\n"
			 "WorkspaceManagers' search path.\n");
		exit(1);
	}
	
	for (i= 1; i < argc; i++){
		if (strrchr(argv[i],'/')) 
			sprintf(outfilename,"%s.tiff",strrchr(argv[i],'/')+1);
		else
			sprintf(outfilename,"%s.tiff",argv[i]);

		printf("Converting %s to TIFF ...",argv[i]); fflush(stdout);
		if ([acrviewer convertACRFile:argv[i] toTiff: outfilename])
		puts("OK"); else puts("ERROR.");
	}
	
}
